﻿/**
 * Peter
 * Created by: Peter Development Team
 *    http://peter.codeplex.com/
 * 
 * GNU General Public License version 2 (GPLv2)
 *    http://peter.codeplex.com/license
 *
 *  This code is provided on an AS IS basis, with no WARRANTIES,
 *  CONDITIONS or GUARANTEES of any kind.
 *
 **/

using System.ComponentModel.Composition;
using Peter.Common.Interfaces;
using Peter.Common.MainMenu;

namespace Peter.Common
{
   /// <summary>
   /// A base dock item for peter.
   /// </summary>
   public abstract class PeterDockItem : ViewModelBase, IDockItem
   {
      #region Fields

      private string m_Title;
      private string m_ToolTip;
      private string m_ContentId;
      private bool m_IsActive;
      private bool m_IsSelected;
      private bool m_AllowClose;
      private bool m_IsEnabled;
      private bool m_CanFloat;
      private MainMenuIcon m_Icon;
      private IPeter m_Peter;

      #endregion

      /// <summary>
      /// Initializes a new dock item.
      /// </summary>
      protected PeterDockItem ()
      {
         this.AllowClose = true;
         this.IsEnabled = true;
         this.CanFloat = true;
      }

      #region Properties

      /// <summary>
      /// Gets the instance of peter.
      /// </summary>
      [Import (typeof (IPeter))]
      public IPeter Peter
      {
         get { return this.m_Peter; }
         set
         {
            this.m_Peter = value;
            this.PeterInstanceResolved ();
            this.RaisePropertyChanged ("Peter");
         }
      }

      /// <summary>
      /// Occurs when the instance of peter is resolved.
      /// </summary>
      protected virtual void PeterInstanceResolved () {}

      /// <summary>
      /// Gets the image source of the dock item.
      /// </summary>
      public MainMenuIcon Icon
      {
         get { return this.m_Icon; }
         protected set
         {
            this.m_Icon = value;
            this.RaisePropertyChanged ("Icon");
         }
      }

      /// <summary>
      /// Gets or Sets if the content is selected.
      /// </summary>
      public bool IsSelected
      {
         get { return this.m_IsSelected; }
         set
         {
            this.m_IsSelected = value;
            this.RaisePropertyChanged ("IsSelected");
         }
      }

      /// <summary>
      /// Gets or Sets if the content is the acitve content.
      /// </summary>
      public bool IsActive
      {
         get { return this.m_IsActive; }
         set
         {
            this.m_IsActive = value;
            this.RaisePropertyChanged ("IsActive");
         }
      }

      /// <summary>
      /// Gets or Sets if the content is enabled.
      /// </summary>
      public bool IsEnabled
      {
         get { return this.m_IsEnabled; }
         set
         {
            this.m_IsEnabled = value;
            this.RaisePropertyChanged ("IsEnabled");
         }
      }

      /// <summary>
      /// Gets or Sets if the content can be closed or not.
      /// </summary>
      public bool AllowClose
      {
         get { return this.m_AllowClose; }
         set
         {
            this.m_AllowClose = value;
            this.RaisePropertyChanged ("AllowClose");
         }
      }

      /// <summary>
      /// Gets or Sets if the content can be a separate floating window or not.
      /// </summary>
      public bool CanFloat
      {
         get { return this.m_CanFloat; }
         set
         {
            this.m_CanFloat = value;
            this.RaisePropertyChanged ("CanFloat");
         }
      }

      /// <summary>
      /// Gets or Sets the title of the content.
      /// </summary>
      public virtual string Title
      {
         get { return this.m_Title; }
         set
         {
            this.m_Title = value;
            this.RaisePropertyChanged ("Title");
         }
      }

      /// <summary>
      /// Gets or Sets the tool tip text.
      /// </summary>
      public virtual string ToolTip
      {
         get { return this.m_ToolTip; }
         set
         {
            this.m_ToolTip = value;
            this.RaisePropertyChanged ("ToolTip");
         }
      }

      /// <summary>
      /// Gets or Sets the dock item's content id.
      /// </summary>
      public string ContentId
      {
         get { return this.m_ContentId; }
         set
         {
            this.m_ContentId = value;
            this.RaisePropertyChanged ("ContentId");
         }
      }

      #endregion
   }
}
